package com.local.cart.feign;

import com.local.cart.pojo.ShoppingCart;
import com.local.common.util.ResultUtil;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@FeignClient("cartservice")
public interface CartServiceFeign {

    /**
     * 查询用户的购物车列表
     * @return
     */
    @GetMapping("/cart/list/{userId}")
    @ResponseBody
    public ResultUtil<List<ShoppingCart>> getListByUserId(@PathVariable("userId") Integer userId);

    /**
     * 加入购物车
     * @param shoppingCart：数据中包含 userId 字段
     * @return
     */
    @PostMapping("/cart")
    @ResponseBody
    public ResultUtil<ShoppingCart> add(@RequestBody ShoppingCart shoppingCart);


    /**
     * 在购物车页面，删除某个商品
     * @return
     */
    @DeleteMapping("/cart/{cartItemId}")
    @ResponseBody
    public ResultUtil delete(@PathVariable("cartItemId") Integer cartItemId);

    /**
     * 在购物车页面，修改商品数量
     * @return
     */
    @PutMapping("/cart")
    @ResponseBody
    public ResultUtil updateGoodsCount(@RequestBody ShoppingCart shoppingCart);

}
